<template>
	<view>
		<view class="flex count">
			<view class="iconfont iconjian" @click="changeNumber(0)"></view>
			<input type="number" :value="num" @input="changeInput">
			<view class="iconfont iconadd"  @click="changeNumber(1)"></view>
		</view>
		
	</view>
</template>

<script>
	export default {
		props:{
			num:{
				type:Number,
				default:1
			}
		},
		data() {
			return {
			};
		},
		methods:{
			changeNumber(type){
				if(type){
					if(this.num < 999){
						this.$emit('update:num',this.num + 1)
					}
					
				}else{
					if(this.num > 1){
						this.$emit('update:num',this.num - 1)
					}
					
				}
			},
			changeInput(e){
				let v = Number(e.detail.value)
				if(v > 0 && v < 999 ){
					this.$emit('update:num',v)
				}else{
					this.$emit('update:num',999)
				}
			}
		}
	}
</script>

<style lang="less">
	.count{
		background: #eee;
		border-radius: 10rpx;
		padding: 0 15rpx;
		.iconfont{
			color:#039702;
			border:unset;
		}
		input{
			width: 60rpx;
			text-align: center;
			font-weight: normal;
		}
	}
</style>
